package com.ncloud.crm.interFace;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSONObject;
import com.ncloud.act.service.ChnlRealBillService;
import com.ncloud.common.enmus.ResultEnum;
import com.ncloud.common.exception.UserException;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import java.text.ParseException;

/**
 * Created by shiqiang on 2017/5/18.
 */
@Service
public class AcctFeeSyncInterface {
    private static final Logger logger = LogManager.getLogger(AcctFeeSyncInterface.class);
    @Reference
    private ChnlRealBillService chnlRealBillService;
    public JSONObject acctFeeSync(JSONObject obj){
        JSONObject param = new JSONObject();
        if(obj == null){
            throw new UserException(ResultEnum.ORDER_INFO_ERROR.getCode(),"当前费用节点不存在！");
        }
        logger.info("同步账管信息报文："+obj.toJSONString());
        try {
            param = chnlRealBillService.insertChnlRealBill(obj);
            logger.info("账管返回信息报文："+param.toJSONString());
        } catch (ParseException e) {
            e.printStackTrace();
            throw new UserException(ResultEnum.DATABASE_ERROR.getCode(),"调用账管接口异常{ChnlRealBillService.insertChnlRealBill(obj)}");
        }
        return param;
    }
    /*生成发送的报文信息在OrderDiscntServiceImpl*/
}
